<template>
    <view class="content">
        <view class="nav">
            <view class="nav-i" :class="{active : type == 0}" @click="chooseNav(0)">待评价</view>
            <view class="nav-i" :class="{active : type == 1}" @click="chooseNav(1)">已评价</view>
        </view>
        
        <view class="item" v-for="(item, index) in list" :key="index" @click="toDetails(item)">
            <view class="i-top" v-for="(el, ind) in item.goods_list" :key="ind" v-if="ind < 1" >
                <image :src="el.image_uri" mode="aspectFit" class="img"></image>
                <view class="item-r">
                    <view class="goods-name">{{el.goods_name}}</view>
                    <!-- <view class="spec">12公斤大容量12公斤大容量12公斤大容量12公斤大容量</view> -->
                    <view class="item-d">
                        <view class="price">￥<text class="price-num">{{el.sale_price}}</text></view>
                        <!-- <view class="deposit">订金￥26.00</view> -->
                        <view class="num">x{{el.goods_nums}}</view>
                    </view>
                </view>
            </view>
            <view class="down">
                <text class="u-font-24">共{{item.goods_list.length}}件商品 实付款：</text>
                <text class="t-p">￥</text>
                <text class="t-p-num">{{item.order_amount}}</text>
            </view>
            <view class="btns" v-if="type == 0">
                <view class="btn2">立即评价</view>
            </view>
        </view>
        
        <view style="height: 94rpx;padding-top: 30rpx;">
            <u-loadmore :status="status" v-if="status != 'loadmore'" />
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                type: 0,
                status: 'loadmore', //是否显示没有更多了
                page: 1,
                list: [], 
            };
        },
        onShow() {
            this.list = []
            this.page = 1
            this.status = 'loadmore'
            this.getList()
        },
        onReachBottom() {
        	if(this.page == 1){return}
        	this.getList()
        },
        methods: {
            chooseNav(num) {
                if (this.type == num) return
                this.type = num
                this.list = []
                this.page = 1
                this.status = 'loadmore'
                this.getList()
            },
            
            toDetails(item) {
                if (this.type == 0) {
                    this.$gTo(`/pages/rate/d-rate?id=${item.id}`)
                } else {
                    this.$gTo(`/pages/rate/y-rate?id=${item.id}`) 
                }
            },
            
            getList() {
            	if (this.status == 'nomore') return;
            	this.status = 'loading';
            	this.$ajax('evaluatesList', {
            		userToken: this.$getSync('userToken'),
            		page: this.page,
            		limit: 10,
                    is_evaluates: this.type, //0-待评价 1-已评价 
            	}).then(ret => {
            		if (ret.status == 0) {
            			if (ret.data.list.length > 0) {
            				this.list = this.list.concat(ret.data.list);
            				this.page++;
            				this.status = 'loadmore'
            			} else {
            				this.status = 'nomore'
            			}
            		} else {
            			this.$toast(ret.message);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    page{
        background-color: #f6f6f6;
    }
    .content{
        padding-bottom: 50rpx;
    }
    .nav{
        border-top: 2rpx solid #ebebeb;
        background-color: #fff;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .nav-i{
        width: calc(100vw / 2);
        padding: 30rpx 0;
        font-size: 28rpx;
        text-align: center;
    }
    .active{
        font-size: 32rpx;
        font-weight: bold;
        color: #00734c;
        border-bottom: 2rpx solid #00734c;
    }
    
    .item{
        padding: 0 20rpx;
        background-color: #fff;
        margin-top: 20rpx;
    }
    .i-top{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20rpx 0;
    }
    .img{
        width: 160rpx;
        height: 160rpx;
        border: 2rpx solid #e3e3e3;
        border-radius: 15rpx;
        overflow: hidden;
        margin-right: 25rpx;
    }
    .item-r{
        flex: 1;
    }
    .goods-name{
        width: 520rpx;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 28rpx;
        font-weight: bold;
    }
    .spec{
        width: 520rpx;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 24rpx;
        color: #6d6d6d;
        padding-top: 5rpx;
    }
    .item-d{
        padding-top: 45rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .price{
        font-size: 26rpx;
    }
    .price-num{
        font-size: 38rpx;
        font-weight: bold;
        padding-right: 30rpx;
    }
    .deposit{
        font-size: 24rpx;
        color: #ff5f2b;
        padding: 4rpx 12rpx;
        background-color: #fff1ec;
        border-radius: 5rpx;
    }
    .num{
        flex: 1;
        font-size: 26rpx;
        color: #929292;
        text-align: right;
    }
    
    .down{
        text-align: right;
        padding-bottom: 25rpx;
    }
    .t-p{
        font-size: 24rpx;
        color: #f62a2a;
    }
    .t-p-num{
        font-size: 38rpx;
        color: #f62a2a;
    }
    .btns{
        padding-bottom: 20rpx;
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }
    .btn2{
        padding: 12rpx 20rpx;
        background-color: #00734c;
        border-radius: 50rpx;
        box-sizing: border-box;
        margin-left: 20rpx;
        color: #fff;
    }

</style>
